home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / propage / data / csep_psprlg next >
Text File  |  1992-03-08  |  5KB  |  246 lines

  1. %=====================================================================%
  2. % Professional Page Color Seperation Prologue file: V3.0, Mar 6, 1992 %
  3. %=====================================================================%
  4. %
  5. % Handles function re-mapping for Color seperation of documents with EPSF files
  6. % with PostScript color commands: 'setrgbcolor, sethsbcolor' as well as
  7. % ColorPostScript commands: `setcmykcolor, currentcmykcolor, colorimage,
  8. % setcolorscreen, currentcolorscreen' + transfer and UCR/GCR commands.
  9.  
  10. /subgray true def
  11. /setrgb /setrgbcolor load def
  12. /sethsb /sethsbcolor load def
  13. /_setgray /setgray load def
  14. /UCR_fctr 0.75 def
  15. /GCR_fctr 1.0 def
  16.  
  17. %
  18. % setgray
  19. %
  20. /setgray {   % g setgray
  21.    subgray
  22.    {
  23.       component 1 gt
  24.       { pop 1.0 }
  25.       if
  26.    }
  27.    if
  28.    _setgray
  29. } bdef
  30.  
  31. %
  32. % Standard PostScript operators:
  33. %
  34.  
  35. % translate rgb into cmyk with UCR/GCR
  36. /setrgbcolor {    % red grn blu setrgbcolor
  37.    % call system setrgbcolor so that currentrgbcolr, currenthsbcolor
  38.    % will still give correct results:
  39.    3 copy setrgb
  40.  
  41.    6 dict begin
  42.  
  43.    1 exch sub /ye exch def
  44.    1 exch sub /ma exch def
  45.    1 exch sub /cy exch def
  46.    ye ma cy add add 3 div /grey exch def
  47.    /blk 0 def
  48.  
  49.    fourcol { % do UCR/GCR
  50.       /min ye def
  51.       ma min lt {/min ma def} if
  52.       cy min lt {/min cy def} if
  53.       min UCR_fctr sub /blk exch def
  54.       blk 0 lt {/blk 0 def} if
  55.  
  56.       ye blk sub /ye exch def
  57.       ma blk sub /ma exch def
  58.       cy blk sub /cy exch def
  59.       blk GCR_fctr mul 1.25 mul /blk exch def
  60.       blk 1 gt {/blk 1 def} if
  61.    } if
  62.  
  63.    % get the component that we want:
  64.    component 0 le {grey} if
  65.    component 1 eq {blk} if
  66.    component 2 eq {ye} if
  67.    component 3 eq {ma} if
  68.    component 4 eq {cy} if
  69.    component 5 ge {0} if
  70.    1 exch sub _setgray
  71.  
  72.    end
  73. } bdef
  74.  
  75. /sethsbcolor {
  76.    sethsb currentrgbcolor setrgbcolor
  77. } bdef
  78.  
  79. %
  80. % Color PostScript operators:
  81. %
  82.  
  83. %/setcmykcolor {  % cy ma ye blk setcmykcolor
  84. %   1 sub 4 1 roll
  85. %   3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat
  86. %   setrgbcolor pop
  87. %} bdef
  88.  
  89. /setcmykcolor {  % cy ma ye blk setcmykcolor
  90.    5 dict begin
  91.  
  92.    /blk exch def
  93.    /ye exch def
  94.    /ma exch def
  95.    /cy exch def
  96.  
  97.    fourcol
  98.    { }
  99.    {
  100.       ye blk add dup 1 gt { pop 1 } if /ye exch def
  101.       ma blk add dup 1 gt { pop 1 } if /ma exch def
  102.       cy blk add dup 1 gt { pop 1 } if /cy exch def
  103.       /blk 0 def
  104.    }
  105.    ifelse
  106.  
  107.    % get the component that we want:
  108.    component 0 le {blk 3 mul ma add ye add cy add 3 div} if
  109.    component 1 eq {blk} if
  110.    component 2 eq {ye} if
  111.    component 3 eq {ma} if
  112.    component 4 eq {cy} if
  113.    component 5 ge {0} if
  114.    1 exch sub _setgray
  115.  
  116.  
  117.    end
  118. } bdef
  119.  
  120. /currentcmykcolor {
  121.    currentgray dup dup dup
  122. } bdef
  123.  
  124. /setcolorscreen {
  125.    component 0 le {12 3 roll} if
  126.    component 1 eq {12 3 roll} if
  127.    component 2 eq {12 -6 roll} if
  128.    component 3 eq {12 -3 roll} if
  129.    % component 4 eq {} if
  130.    component 5 ge
  131.    {12 {pop} repeat}
  132.    {9 {pop} repeat setscreen}
  133.    ifelse
  134. } bdef
  135.  
  136. /currentcolorscreen {
  137.    currentscreen 3 copy 3 copy 3 copy
  138. } bdef
  139.  
  140. /setcolortransfer {
  141.    component 0 le {4 1 roll} if
  142.    component 1 eq {4 1 roll} if
  143.    component 2 eq {4 -2 roll} if
  144.    component 3 eq {4 -1 roll} if
  145.    % component 4 eq {} if
  146.    component 5 ge
  147.    { pop pop pop pop}
  148.    {pop pop pop settransfer}
  149.    ifelse
  150. } bdef
  151.  
  152. /currentcolortransfer {
  153.    currenttransfer dup dup dup
  154. } bdef
  155.  
  156. /setblackgeneration {
  157.    pop
  158. } bdef
  159. /currentblackgeneration {
  160.    {}
  161. } bdef
  162.  
  163. /setundercolorremoval {
  164.    pop
  165. } bdef
  166.  
  167. /currentundercolorremoval {
  168.    {}
  169. } bdef
  170.  
  171. /colorimage { % width height bps matrix proc0 [...procn-1] multi ncol colorimage
  172.    10 dict begin
  173.    /ncol exch def
  174.    /multi exch def
  175.    ncol 4 eq multi and {
  176.       /proc3 exch def
  177.    } if
  178.    ncol 3 ge multi and {
  179.       /proc2 exch def
  180.       /proc1 exch def
  181.    } if
  182.    /proc0 exch def
  183.    /mat exch def
  184.    /bps exch def
  185.    /height exch def
  186.  
  187.    height bps mat
  188.  
  189.    ncol 1 eq
  190.    {    % just B&W data
  191.       component 1 le
  192.       {{proc0} image}
  193.       {height {proc0 pop} repeat 4 {pop} repeat}
  194.       ifelse
  195.    }
  196.    {
  197.       multi
  198.       {
  199.      /trsave currenttransfer def
  200.      % CMYK (4 color) is dark-high, `image' wants light-high
  201.      % so invert image:
  202.      ncol 4 eq {{.999 exch sub trsave} bind settransfer} if
  203.      component 1 le { % B&W or Black component
  204.         ncol 3 eq
  205.         {height {proc0 pop proc1 pop proc2 pop} repeat 4 {pop} repeat}
  206.         {{proc0 pop proc1 pop proc2 pop proc3} image}
  207.         ifelse
  208.      } if
  209.      component 2 eq { % Yellow component
  210.         ncol 3 eq
  211.         {{proc0 pop proc1 pop proc2} image}
  212.         {{proc0 pop proc1 pop proc2 proc3 pop} image}
  213.         ifelse
  214.      } if
  215.      component 3 eq { % Magenta component
  216.         ncol 3 eq
  217.         {{proc0 pop proc1 proc2 pop} image}
  218.         {{proc0 pop proc1 proc2 pop proc3 pop} image}
  219.         ifelse
  220.      } if
  221.      component 4 eq { % Cyan component
  222.         ncol 3 eq
  223.         {{proc0 proc1 pop proc2 pop} image}
  224.         {{proc0 proc1 pop proc2 pop proc3 pop} image}
  225.         ifelse
  226.      } if
  227.      component 5 ge { % Mechanical color
  228.         ncol 3 eq
  229.         {height {proc0 pop proc1 pop proc2 pop} repeat 4 {pop} repeat}
  230.         {height {proc0 pop proc1 pop proc2 pop proc3 pop} repeat 4 {pop} repeat }
  231.         ifelse
  232.      } if
  233.      /trsave load settransfer
  234.       }
  235.       {  % not multiproc - can't do anything
  236.      height {proc0 pop} repeat 4 {pop} repeat
  237.       }
  238.       ifelse
  239.    }
  240.    ifelse
  241.    end
  242. } bdef
  243.  
  244.  
  245.  
  246.